#include <iostream>
#include <cmath>
using namespace std;

class Date
{
private:
  int day, month, year;

public:
  Date()
  {
    int y = 1900;
    int m = 1;
    int d = 1;
  };
                                      //构造函数
  void SetDate(int yy, int mm, int dd); //日期设置
  bool IsLeapYear();                    //是否闰年
  void print_ymd();                     //年月日输出
  void print_mdy();                     //月日年输出
};

void Date::SetDate(int yy, int mm, int dd)
{
  month = (mm >= 1 && mm <= 12) ? mm : 1;        //月份有效性判断
  year = (yy >= 1900 && yy <= 2100) ? yy : 1900; //年份有效性判断
  switch (month)
  {
    //小月天数判断
  case 4:
  case 6:
  case 9:
  case 11:
    day = (dd >= 1 && dd <= 30) ? dd : 1;
    break;
  case 2: //二月天数判断
    if (IsLeapYear())
      day = (dd >= 1 && dd <= 29) ? dd : 1;
    else
      day = (dd >= 1 && dd < 28) ? dd : 1;
    break;
  default: //小月剩下的就是大月
    day = (dd >= 1 && dd <= 31) ? dd : 1;
  }
}

//闰年判断
bool Date::IsLeapYear()
{
  if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))
    return true;
  else
    return false;
}

void Date::print_ymd()
{
  cout << year << "-" << month << "-" << day << endl;
}
void Date::print_mdy()
{
  char *monthName[12] = {"January", "February", "March", "April", "May", "June",
                         "August", "September", "October", "November", "December"};
  cout << monthName[month - 1] << "-" << day << "-" << year << endl;
}

int main()
{
  Date date1;
  date1.SetDate(2015, 1, 1);
  cout << "the current date is"<<endl;
  date1.print_mdy();
  date1.print_ymd();

  date1.SetDate(2015, 2, 29);

  cout << "the current date is"<<endl;
  date1.print_mdy();
  date1.print_ymd();

  return 0;
}